﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class properties_list : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!Page.IsPostBack)
            pageContentHolder.InnerHtml = buildPropertyList();
    }
    private string buildPropertyList()
    {

        List<PomplingProperty> propertyList = PomplingProperty.SelectPageProperties(0, 20);
        string html = string.Empty;
        string altText = string.Empty;
        for (int i = 0; i < propertyList.Count; i++)
        {
            if (string.IsNullOrWhiteSpace(propertyList[i].DisplayPicturePath))
                altText = "Image comming soon!";
            else altText = string.Empty;
            html += "<div class=\"lettingContainer\">" + Environment.NewLine + 
                " <div class=\"divPropertyThumbHolder\"> " + Environment.NewLine + 
                    " <a href=\"property_item.aspx?a=" + propertyList[i].PomplingAddressID + "\">"
                + "<img src=\"" + "./" + propertyList[i].DisplayPicturePath + "\" " + " alt=\"" + altText + " " + propertyList[i].AddressLine1 + " bed property " + propertyList[i].City + " " + propertyList[i].Postcode + "\" " +
                " title=\"" + propertyList[i].NumberOfBedrooms + " bed property " + propertyList[i].City + " " + propertyList[i].Postcode + "\" " +
                " height=\"150\" width=\"150\" class=\"propertyThumb\" /> </a> " +
                Environment.NewLine + "</div>" +
                Environment.NewLine + "<div class=\"divlettingContainerText\"> " +
                Environment.NewLine + "<p class=\"houseDescription\"><strong> £" + propertyList[i].PricePerCalendarMonth + " PCM</strong></p><br /> " +
                Environment.NewLine + " <p class=\"houseDescription\">" + propertyList[i].NumberOfBedrooms + " bed property</p> " +
                Environment.NewLine + " <p class=\"houseDescription\"> <a href=\"property_item.aspx?a=" + propertyList[i].PomplingAddressID + "\">" + propertyList[i].AddressLine1 + " " + propertyList[i].City + " " + propertyList[i].County + "</a></p>" +
                Environment.NewLine + " <p class=\"houseDescription\">" + propertyList[i].ShortDescription + "</p> " +
                Environment.NewLine + " </div>" + Environment.NewLine + "</div>";
        }
        return html;
    }
}